import { seq } from "../db"
import { DataTypes, Model, Optional } from "sequelize"
import * as path from "path"
//权限等级分两种，一种最高权限，一种普通权限
enum roleType {
    BOSS = "boss",
    ADMIN = "admin"
}
const roles = ["admin", "boss"]

interface IClue {
    name: string //第一章，第二章。。。
    pics:string[] //线索图片列表
}

interface IRoles {
    [key:string]:string[]
}

interface IBaseScript {
    scriptName: string  //剧本名字
    manNum: number   //剧本男性数量
    womenNum: number  //剧本女性数量
    introduction: string    //剧本简介
    cover:string //剧本封面
    clue:IClue[] //线索
    role:IRoles //角色
    is_selected: boolean //是否是精选
    is_deleted: boolean    //是否删除
}

interface IScriptInstance extends Model {
    scriptName: string  //剧本名字
    manNum: number   //剧本男性数量
    womenNum: number  //剧本女性数量
    introduction: string    //剧本简介
    cover:string //剧本封面
    clue:IClue[] //线索
    role:IRoles //角色
    is_selected: boolean //是否是精选
    is_deleted: boolean    //是否删除

}








const ScriptModel = seq.define<IScriptInstance>('Script', {
    // 在这里定义模型属性
    scriptName: {
        type: DataTypes.STRING,
        comment: "剧本名",
        unique: true,
        allowNull: false
    },
    manNum: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: "男性数量"
        // allowNull 默认为 true
    },
    womenNum: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: "女性数量"
    },
    introduction: {
        type: DataTypes.STRING,
        defaultValue: "还未填写任何简介",
        comment: "剧本简介"
    },
    cover: {
        type: DataTypes.STRING,
        comment: "剧本封面"
    },
    clue: {
        type:DataTypes.JSON,
        comment:"线索"
    },
    role: {
        type:DataTypes.JSON,
        comment:"角色"
    },
    is_selected: {
        type:DataTypes.BOOLEAN,
        comment:"是否是精选",
        defaultValue: false,
    },
    is_deleted: {
        type: DataTypes.BOOLEAN,
        defaultValue: false,
        comment: "是否删除，默认不删除"

    }

}, {
    // 这是其他模型参数
    tableName: 'scripts'
});






export {
    ScriptModel,
    IScriptInstance,
    IBaseScript
}








